package cn.wen.forum.common.config;

import cn.wen.forum.common.Filter.ForumFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName FilterConfig
 * @Author By wen
 * @Description
 * @Date 2023/3/20 10:18
 * @Version 1.0
 */
@Configuration
public class FilterConfig {

    @Autowired
    ForumFilter forumFilter;

    @Bean
    public FilterRegistrationBean baseFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(forumFilter);
        filterRegistrationBean.addUrlPatterns("/forum/*");
        filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }
}
